package com.example.git03;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class tiaozhuan_Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_tiaozhuan);

        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.tiaozhuan), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        EditText etPassword = findViewById(R.id.etPassword);
        EditText etConfirmPassword = findViewById(R.id.etConfirmPassword);
        Button btnSubmit = findViewById(R.id.btnSubmit);
        TextView tvMessage = findViewById(R.id.tvMessage);

        btnSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String password = etPassword.getText().toString();
                String confirmPassword = etConfirmPassword.getText().toString();

                if (password.equals(confirmPassword)) {
                    // 密码一致，显示修改成功，并跳转回登录界面
                    tvMessage.setText("创建成功");
                    Toast.makeText(tiaozhuan_Activity.this, "创建成功", Toast.LENGTH_SHORT).show();
                    Intent intent = new Intent(tiaozhuan_Activity.this, LoginActivity.class);
                    startActivity(intent);
                } else {
                    // 密码不一致，提示重新输入
                    tvMessage.setText("密码不一致，请重新输入！");
                    Toast.makeText(tiaozhuan_Activity.this, "密码不一致，请重新输入！", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}